package ferp.center.server.entity;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import ferp.center.network.request.RequestBidAdd;

import javax.persistence.*;
import java.util.Date;

/**
 * User: igorgok
 * Date: 12/5/12 9:53 AM
 */

@Entity
public class Bid
{
/*
  public Key getKey() {return key;}
  public Profile getProfile(EntityManager em) {return em.find(Profile.class, profile);}
  public void setProfile(long id) {this.profile = KeyFactory.createKey("Profile", id);}
  public void setProfile(Profile profile) {this.profile = profile.getKey();}
  public void setCreated(Date date) {this.created = date;}
*/

  public int getHand() {return hand;}
  public int getCards() {return cards;}
  public int getPenalty() {return penalty;}
  public char getResult() {return result.charAt(0);}
  public char getLast() {return last.charAt(0);}
  public int getStartingTricks() {return starting;}

  public Bid() {}
  public Bid(RequestBidAdd rba)
  {
    profile = KeyFactory.createKey(Profile.class.getSimpleName(), rba.profile);
    configuration = rba.configuration;
    created = new Date();
    hand = rba.hand;
    cards = rba.cards;
    penalty = rba.penalty;
    result = "" + rba.result;
    last = "" + rba.last;
    starting = rba.starting;
    pool = rba.pool;
    score = rba.score;
/*
    tricks = rba.tricks;
    trump = rba.trump;
*/
  }

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Key key;
  // profile
  private Key profile;
  // configuration
  private String configuration;
  // player's accumulated pool
  private long pool;
  // player's accumulated score
  private long score;
  // creation date
  @Temporal(TemporalType.DATE)
  private Date created;
  // hand in game
  private int hand;
  // cards in hand
  private int cards;
  // pass penalty
  private int penalty;
  // bid result
  private String result;
  // last bid if any
  private String last;
  // starting tricks
  private int starting;

/*
  // tricks
  private int tricks;
  // trump
  private char trump;
*/

  @Version
  private int version;
}
